//
//  MainLogin.swift
//  weibo
//
//  Created by Mike on 15/5/10.
//  Copyright (c) 2015年 Mike. All rights reserved.
//

import UIKit

class MainLoginView: UIView {

    
    @IBOutlet weak var circleView: UIImageView!
    @IBOutlet weak var picView: UIImageView!

    @IBOutlet weak var messageLabel: UILabel!
    weak var delegate:MainLoginViewDelegate?
    
    // 设置界面
    func setupInfo(picViewName:String, msg: String, isHome:Bool = false) {
        self.circleView.hidden = !isHome
        
        self.picView.image = UIImage(named: picViewName)
        
        
        self.messageLabel.text = msg
        
        isHome ? startAnimate() : stopAnimate()
        
        
    }
    func startAnimate() {
        println("是主页，开始动画")
        
        
        let anim = CABasicAnimation(keyPath: "transform.rotation")
        anim.toValue = 2 * M_PI
        anim.repeatCount = MAXFLOAT
        anim.duration = 20.0
        
        self.circleView.layer.addAnimation(anim, forKey: nil)
    }
    func stopAnimate() {
        println("不是主页，停止动画")
    }
    
    
    @IBAction func loginClick() {
        println("点击了登录")
        self.delegate?.loginDidClicked(self)
    }
    @IBAction func registClick() {
        println("点击了注册")
        self.delegate?.registDidClicked(self)
    }
}



protocol MainLoginViewDelegate: NSObjectProtocol {
    func loginDidClicked(view: MainLoginView)
    func registDidClicked(view: MainLoginView)
}
